<?php


namespace core\page;


use DomainException;
use think\paginator\driver\Bootstrap;

/**
 * 替换原来的分页类 修改了 data改成 records
 * Class PageBootstrap
 * @package support
 */
class PageBootstrap extends Bootstrap
{

    /**
     * 转换为数组.
     *
     * @return array
     */
    public function toArray(): array
    {
        try {
            $total = $this->total();
        } catch (DomainException $e) {
            $total = null;
        }
        return [
            'total' => $total,
            'per_page' => $this->listRows(),
            'current_page' => $this->currentPage(),
            'last_page' => $this->lastPage,
            'has_more' => $this->hasMore,
            'rows' => $this->items->toArray(),
        ];
    }

}